package com.wangzh.network.tcp.uploadthread;

import java.io.*;
import java.net.Socket;

public class Client {
    public static void main(String[] args) throws IOException {
        //创建Socket对象并连接服务端
        Socket socket = new Socket("127.0.0.1", 10000);

        //读取本地文件数据
        BufferedInputStream bis = new BufferedInputStream(new FileInputStream("D:\\learn\\aa.mp4"));


        BufferedOutputStream bos = new BufferedOutputStream(socket.getOutputStream());
        byte[] bytes = new byte[1024];
        int len;
        while ((len = bis.read(bytes)) != -1) {
            bos.write(bytes,0,len);
        }

        //往服务器写结束标记
        socket.shutdownOutput();

        //接收服务器的回写数据
        BufferedReader bf = new BufferedReader(new InputStreamReader(socket.getInputStream()));
        String s = bf.readLine();
        System.out.println(s);

        socket.close();
    }
}
